package m3d29;

public class rChihuo extends Thread{

    //创包子
    private pBaozi bz;

    //构造为包子赋值
    public rChihuo(pBaozi bz) {
        this.bz = bz;
    }

    @Override
    public void run() {
        while(true){
            synchronized (bz){
                if(bz.flag==false){
                    try {
                        bz.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

                //被唤醒后吃包子
                System.out.println("正在吃");

                bz.flag=false;

                bz.notify();
                System.out.println("吃完了");
                System.out.println("===================");
            }
        }
    }
}
